package com.htc.android.footprints.view;

import android.content.Context;
import android.hardware.Camera;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.htc.android.footprints.activity.FootprintCamera;
import com.htc.android.footprints.utils.FootprintUtils;

public class BrightnessPanel extends RelativeLayout
{
  private static final String TAG = "BrightnessPanel";
  View.OnClickListener bright_desc = new View.OnClickListener()
  {
    public void onClick(View paramView)
    {
      if ((BrightnessPanel.this.mCameraDevice != null) && (BrightnessPanel.this.mHandler != null))
        BrightnessPanel.this.getDefault();
      if ((BrightnessPanel.this.mCurrentValue == BrightnessPanel.this.mMin) || (BrightnessPanel.this.mCurrentValue < BrightnessPanel.this.mMin))
        BrightnessPanel.this.mCurrentValue = BrightnessPanel.this.mMin;
      while (true)
      {
        return;
        int i = BrightnessPanel.this.mCurrentValue - 1;
        Log.d("BrightnessPanel", "bright_desc:" + BrightnessPanel.this.bright_desc + " / mCurrentValue:" + BrightnessPanel.this.mCurrentValue);
        ((FootprintCamera)BrightnessPanel.this.mContext).resetBrightnessPanel();
        FootprintUtils.setCameraBrightness(BrightnessPanel.this.mCameraDevice, i);
        FootprintUtils.putBrightPreferences(BrightnessPanel.this.mContext, i);
        BrightnessPanel.this.refreshLevelBar(BrightnessPanel.this.mLevelBar, i);
      }
    }
  };
  View.OnClickListener bright_insc = new View.OnClickListener()
  {
    public void onClick(View paramView)
    {
      if ((BrightnessPanel.this.mCameraDevice != null) && (BrightnessPanel.this.mHandler != null))
        BrightnessPanel.this.getDefault();
      if ((BrightnessPanel.this.mCurrentValue > BrightnessPanel.this.mMax) || (BrightnessPanel.this.mCurrentValue == BrightnessPanel.this.mMax))
        BrightnessPanel.this.mCurrentValue = BrightnessPanel.this.mMax;
      while (true)
      {
        return;
        int i = 1 + BrightnessPanel.this.mCurrentValue;
        Log.d("BrightnessPanel", "bright_desc:" + BrightnessPanel.this.bright_desc + " / mCurrentValue:" + BrightnessPanel.this.mCurrentValue);
        ((FootprintCamera)BrightnessPanel.this.mContext).resetBrightnessPanel();
        FootprintUtils.setCameraBrightness(BrightnessPanel.this.mCameraDevice, i);
        FootprintUtils.putBrightPreferences(BrightnessPanel.this.mContext, i);
        BrightnessPanel.this.refreshLevelBar(BrightnessPanel.this.mLevelBar, i);
      }
    }
  };
  private ImageView mBrightDesc;
  private ImageView mBrightInsc;
  private TextView mBrightnessData;
  public Camera mCameraDevice;
  private Context mContext;
  int mCurrentValue;
  int mDefaultValue;
  public Handler mHandler;
  private ViewGroup mLevelBar;
  int mListSelectIndex = 0;
  int mMax;
  int mMin;
  int mRange;
  int mStep;

  public BrightnessPanel(Context paramContext)
  {
    super(paramContext);
    this.mContext = paramContext;
    initView();
  }

  public BrightnessPanel(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    this.mContext = paramContext;
    initView();
  }

  private void getDefault()
  {
    if (this.mCameraDevice != null)
    {
      this.mCurrentValue = Integer.valueOf(this.mCameraDevice.getParameters().get("brightness")).intValue();
      this.mStep = 1;
      this.mMax = 9;
      this.mMin = 1;
      this.mDefaultValue = 5;
      this.mRange = (this.mMax - this.mMin);
    }
    while (true)
    {
      return;
      Log.d("BrightnessPanel", "no camera device");
    }
  }

  private void initView()
  {
    addView((ViewGroup)((LayoutInflater)this.mContext.getSystemService("layout_inflater")).inflate(2130903043, null));
    getDefault();
    this.mBrightDesc = ((ImageView)findViewById(2131492886));
    this.mBrightInsc = ((ImageView)findViewById(2131492887));
    this.mBrightnessData = ((TextView)findViewById(2131492884));
    this.mBrightDesc.setOnClickListener(this.bright_desc);
    this.mBrightInsc.setOnClickListener(this.bright_insc);
    this.mBrightnessData.setText(2131361924);
    setClickable(true);
    this.mLevelBar = ((ViewGroup)findViewById(2131492885));
  }

  private void refreshLevelBar(ViewGroup paramViewGroup, int paramInt)
  {
    int i = paramViewGroup.getChildCount();
    for (int j = 0; j < i; j++)
      ((ImageView)paramViewGroup.getChildAt(j)).setImageResource(2130837528);
    ImageView localImageView = (ImageView)paramViewGroup.getChildAt(paramInt - 1);
    if (localImageView != null)
      localImageView.setImageResource(2130837529);
    this.mBrightnessData.setText("Brightness " + paramInt);
  }

  private void setBrightnessData(int paramInt)
  {
    this.mBrightnessData.setText(paramInt);
  }

  public void init(Camera paramCamera, Handler paramHandler)
  {
    this.mCameraDevice = paramCamera;
    this.mHandler = paramHandler;
    getDefault();
    if (this.mLevelBar != null)
      refreshLevelBar(this.mLevelBar, FootprintUtils.getBrightPreferences(this.mContext));
  }

  public void setCameraDevice(Camera paramCamera)
  {
    this.mCameraDevice = paramCamera;
  }

  public void setCameraHandler(Handler paramHandler)
  {
    this.mHandler = paramHandler;
  }

  public void showBrightPanel(int paramInt)
  {
    FootprintUtils.setCameraBrightness(this.mCameraDevice, FootprintUtils.getBrightPreferences(this.mContext));
    getDefault();
    Animation localAnimation = AnimationUtils.loadAnimation(this.mContext, 2130968587);
    localAnimation.setDuration(150L);
    startAnimation(localAnimation);
    setVisibility(paramInt);
  }

  public static abstract interface onLevelSelectListener
  {
    public abstract void onSelect(int paramInt1, int paramInt2);
  }
}

/* Location:           E:\workspace\dex2java\dex-translator-0.0.9.3\HtcFootprints_dex2jar.jar
 * Qualified Name:     com.htc.android.footprints.view.BrightnessPanel
 * JD-Core Version:    0.6.0
 */